package com.lll.springbootkafka.kafka;

import com.lll.springbootkafka.kafka.bean.producer.UserLogProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

@SpringBootApplication
@Slf4j
public class KafkaApplication {

    /**
     * 生产者
     */
    @Autowired
    private UserLogProducer userLogProducer;

    /**
     * 初始化，构造器执行后执行
     */
    @PostConstruct
    public void init() {
        for (int i = 0; i < 10; i++) {
            userLogProducer.sendLogMsg(String.valueOf(i));
            log.info(">>>>正在发送第{}条消息！", i + 1);
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(KafkaApplication.class, args);
    }

}
